import { ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsOptional, IsPositive, Min } from 'class-validator';

/**
 * 分页查询 DTO
 */
export class PaginationDto {
  @ApiPropertyOptional({ description: '页码', minimum: 1, default: 1 })
  @Type(() => Number)
  @IsOptional()
  @IsPositive({ message: '页码必须是正整数' })
  page?: number = 1;

  @ApiPropertyOptional({ description: '每页数量', minimum: 1, default: 10 })
  @Type(() => Number)
  @IsOptional()
  @Min(1, { message: '每页数量最少为1' })
  limit?: number = 10;

  @ApiPropertyOptional({ description: '搜索关键词' })
  @IsOptional()
  keyword?: string;
}